package com.example.tourstor;

import android.support.annotation.NonNull;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import java.util.ArrayList;

/**
 * Created by Air on 2018-08-27.
 */

public class QuizAdapter extends BaseAdapter {
    private static final String TAG="QuizAdapter";
    ArrayList<Quiz> list;
    private LayoutInflater layoutInflater;
    public QuizAdapter(LayoutInflater layoutInflater, ArrayList<Quiz> list){
        this.layoutInflater=layoutInflater;
        this.list=list;
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int position) {
        return position;
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @NonNull
    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        View view=layoutInflater.inflate(R.layout.main_item,null);
        Quiz quiz=list.get(position);

        TextView fuzerentext=(TextView) view.findViewById(R.id.fuzeren_main);
        fuzerentext.setText(quiz.getFuzeren());
        TextView mudiditext=(TextView) view.findViewById(R.id.mudidi_main);
        mudiditext.setText(quiz.getMudidi());
        TextView chufatext=(TextView) view.findViewById(R.id.chufa_main);
        chufatext.setText(quiz.getChufa());
        TextView feiyongtext=(TextView) view.findViewById(R.id.feiyong_main);
        feiyongtext.setText(quiz.getFeiyong());
        TextView tuanhaotext=(TextView) view.findViewById(R.id.tuanhao_main);
        String tuanhao = String.valueOf(quiz.getTuanhao());
        tuanhaotext.setText(tuanhao);
        TextView renshutext=(TextView) view.findViewById(R.id.renshu_main);
        renshutext.setText(quiz.getRenshu());
        TextView muqiantext=(TextView) view.findViewById(R.id.muqian_main);
        muqiantext.setText(quiz.getMuqian());

        return view;
    }
}
